package hotciv.variants;

import hotciv.framework.City;
import hotciv.framework.Game;
import hotciv.framework.GameConstants;
import hotciv.framework.Player;
import hotciv.framework.Position;
import hotciv.framework.WinnerStrategy;

public class BetaWinner implements WinnerStrategy {

	@Override
	public Player getWinner(Game game) {
		Player winner = null;
		outerloop: 
		for (int i=0;i<GameConstants.WORLDSIZE;i++) {
			for(int j=0;j<GameConstants.WORLDSIZE;j++) {
				City city = game.getCityAt(new Position(i, j));
				if (city != null) {
					if (winner==null) winner = city.getOwner();
					else if (city.getOwner() != winner) {
						winner = null;
						break outerloop;
					}
				}
			}
		}
		return winner;
	}

}
